'use strict';

const conn = require('../../libs/DB/Conn');
const operationRecord = require("../sys/operationRecordAction");

module.exports = async function (params) {
    /*if(params.functionType !== 0){
        let repeatSum = await conn(`SELECT count(*) sum FROM user_group WHERE function_type = ? AND delete_sign = 1`,[params.functionType]);
        if(repeatSum[0].sum > 0){
            return {success:false,message:'已存在赋予此职能的用户组'}
        }
    }*/
    let insertObj = {
        group_name: params.groupName,
        is_manager: 0,
        domain_id:params.userDomainId
    };
    let sql = `INSERT INTO user_group SET ? `;
    let insertResult = await conn(sql, [insertObj]);
    let insertId = insertResult.insertId;
    await operationRecord(params);
    return {success: true, insertId: insertId};
};
